/**  
 * All rights Reserved, Designed By <a href="www.itttq.com" target="_blank">www.itttq.com</a>
 * @date:   2017-07-21 11:42:21
 * @Copyright: 2017 <a href="www.itttq.com" target="_blank">www.itttq.com</a> Inc. All rights reserved. 
 */
package com.itttq.gshop.pbpm.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Lang;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;

import com.itttq.gshop.domain.po.UserAddressPo;
import com.itttq.gshop.pbpm.cmpt.mybatis.CustomInLanguage;
import com.itttq.gshop.pbpm.provider.UserAddressSqlProvider;

@Mapper
public interface IUserAddressMapper {
	/**
	 * 新增UserAddressPo对象
	 * 
	 * @param UserAddressPo
	 * @Author 迷蝶
	 * @return Integer
	 */
	@InsertProvider(type=UserAddressSqlProvider.class,  method="addUserAddress") 
	@Options(useGeneratedKeys = true, keyProperty = "id")
	public Integer addUserAddress(UserAddressPo userAddress);

	/**
	 * 更新UserAddressPo对象
	 * 
	 * @param userAddressPo
	 * @Author 迷蝶
	 * @return Integer
	 */
	@UpdateProvider(type=UserAddressSqlProvider.class,  method="updateUserAddress") 
	public Integer updateUserAddress(UserAddressPo userAddress);

	/**
	 * 更新地址为非默认地址
	 * 
	 * @param userId	用户ID
	 * @Author 迷蝶
	 * @return Integer
	 */
	@Update("UPDATE user_address SET default_addr=2 WHERE user_id =#{userId}")
	public Integer updateDefaultAddr(int userId);
	
	/**
	 * 根据ID删除UserAddressPo对象
	 * 
	 * @param id
	 * @Author 迷蝶
	 * @return Integer
	 */
	@DeleteProvider(type=UserAddressSqlProvider.class,  method="delUserAddress") 
	public Integer delUserAddressById(Integer id);

	/**
	 * 根据IDS删除UserAddressPo对象
	 * 
	 * @param ids
	 * @Author 迷蝶
	 * @return List<UserAddressPo>
	 */
	@Lang(CustomInLanguage.class)
	@Delete("DELETE FROM user_address WHERE id IN (#{ids})")
	public Integer delUserAddressByIds(@Param("ids") List<Integer> ids);
	
	/**
	 * 根据条件查找UserAddressPo对象，默认根据ID降序
	 * 
	 * @param userAddressPo
	 * @Author 迷蝶
	 * @return List<UserAddressPo>
	 */
	@SelectProvider(type=UserAddressSqlProvider.class,  method="findUserAddresss") 
	public List<UserAddressPo> findUserAddresss(UserAddressPo userAddress);
	
	/**
	 * 根据条件查找记录总数
	 * 
	 * @param userAddressPo
	 * @Author 迷蝶
	 * @return Integer
	 */
	@SelectProvider(type=UserAddressSqlProvider.class,  method="findUserAddressCount") 
	public Integer findUserAddressCount(UserAddressPo userAddress);

	/**
	 * 根据ID查找UserAddressPo对象
	 * 
	 * @param id
	 * @Author 迷蝶
	 * @return UserAddressPo
	 */
	@SelectProvider(type=UserAddressSqlProvider.class,  method="findUserAddressById") 
	public UserAddressPo findUserAddressById(Integer id);
	
}